﻿def CheckValidityWarhammer():
	List.ErrorMessage = ""
	list_total = List.Total
	entries = List.GetEntries()
	lord_count = int(entries.GetEntriesByCategory("1.Lords").Count)
	hero_count = int(entries.GetEntriesByCategory("2.Heroes").Count)
	core_count = int(entries.GetEntriesByCategory("3.Core").Count)
	special_count = int(entries.GetEntriesByCategory("4.Special").Count)
	rare_count = int(entries.GetEntriesByCategory("5.Rare").Count)

	max_heroes = 3
	max_lords = list_total / 2000
	max_special = 3
	max_rare = 1
	min_core = 2

	if max_lords < 0:
		max_lords = 0

	max_heroes += max_lords * 2
	max_special += max_lords * 2
	max_rare += max_lords * 2
	min_core += max_lords * 2

	if int(lord_count) > int(max_lords):
		List.ErrorMessage = "Too many lords"
	elif int(hero_count) > int(max_heroes):
		List.ErrorMessage = "Too many heroes"
	elif int(special_count) > int(max_special):
		List.ErrorMessage = "Too many special choices"
	elif int(rare_count) > int(max_rare):
		List.ErrorMessage = "Too many rare choices"
	elif int(core_count) < int(min_core):
		List.ErrorMessage = "Not enough core choices"